import {deleteComment} from "@/api/comment";
import { MessageBox,Message } from 'element-ui';
const comment = {
    state:{
        commentList: [],
    },

    mutations: {
        SET_COMMENT_LIST(state,data){
            state.commentList = data
        }
    },

    actions:{
        deleteComment(context, data) {
            MessageBox.confirm('确定删除该评论吗?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                deleteComment(data.commentId,data.blogId).then( res => {
                    if (res.status) {
                        Message.success('删除成功')
                        context.commit('SET_COMMENT_LIST',res.data)
                    }
                })
            }).catch(() => {
            });
        }
    }
}

export default comment
